package top.api.controller;

import cn.dev33.satoken.annotation.SaCheckLogin;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import top.api.common.ResUlt;
import top.api.domain.dto.GroupInfoDto;
import top.api.service.GroupInfoService;
import top.api.service.UploadService;


@RestController
@RequestMapping("/group")
@AllArgsConstructor
@Api(tags = "群组管理")
public class MyGroupInfoController {
    private final GroupInfoService groupInfoService;

    private final UploadService uploadService;

    @RequestMapping("/saveGroup")
    @SaCheckLogin
    @ApiOperation("保存群组信息")
    public ResUlt<?> getAllGroup(@RequestBody @Validated GroupInfoDto groupInfoDto){
        return groupInfoService.saveGroupInfo(groupInfoDto);
    }

    @RequestMapping("/uploadImg")
    @SaCheckLogin
    @ApiOperation("上传照片")
    public ResUlt<?> getImages(MultipartFile img){
       return uploadService.upload(img);
    }
}
